package com.example.fechat.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.example.fechat.R
import com.example.fechat.adapter.DiscoverAdapter
import com.example.fechat.base.BaseAdapter
import com.example.fechat.bean.ChatBean
import com.example.fechat.bean.DiscoverBean

class DiscoverFragment : Fragment() {
    private lateinit var recyclerView: RecyclerView
    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        val view = inflater.inflate(R.layout.fragment_discover, container, false)
        recyclerView = view.findViewById(R.id.recyclerView)
        val data = ArrayList<DiscoverBean>()
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_friend, 0, null),
                "朋友圈",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_discover, 0, null),
                "视频号",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_live, 0, null),
                "直播",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_sao, 0, null),
                "扫一扫",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_yao, 0, null),
                "摇一摇",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_kan, 0, null),
                "看一看",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_sou, 0, null),
                "搜一搜",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_near, 0, null),
                "附近",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_buy, 0, null),
                "购物",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_game, 0, null),
                "游戏",
            )
        )
        data.add(
            DiscoverBean(
                context?.resources?.getDrawableForDensity(R.drawable.icon_applet, 0, null),
                "小程序",
            )
        )
        recyclerView.layoutManager = LinearLayoutManager(context)
        val adapter = DiscoverAdapter(data)
        recyclerView.adapter = adapter
        adapter.setOnItemClickListener(object : DiscoverAdapter.OnItemClickListener {
            override fun onItemClick(view: View, position: Int) {

            }
        })
        return view
    }
}